home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
edit
/
pt20pc.zip
/
SUPPORT.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-02-04
|
17KB
|
692 lines
DGROUP GROUP CONST, _BSS, _DATA
ASSUME DS: DGROUP, SS: DGROUP, ES: DGROUP
;
SUPPORT_TEXT SEGMENT WORD PUBLIC 'CODE'
SUPPORT_TEXT ENDS
;
CONST SEGMENT WORD PUBLIC 'CONST'
CONST ENDS
;
_BSS SEGMENT WORD PUBLIC 'BSS'
assume ds:dgroup
extrn _evtail:word
extrn _evaddr:word
_BSS ENDS
;
_DATA SEGMENT WORD PUBLIC 'DATA'
assume ds:dgroup
minus1 dw -1
minus2 dw -2
_DATA ENDS
;
SUPPORT_TEXT SEGMENT WORD PUBLIC 'CODE'
assume cs:SUPPORT_TEXT
assume ds:dgroup
public _evinit, _mbintr
;
;
;************************ _repword *************************
; XTAG:repword
public _repword
;
; repword(wordToReplicate, startAddress, numberOfReplications);
; char *startAddress;
; int wordToReplicate, numberOfReplications;
;
_repword proc far
push bp ; save bp
mov bp,sp ; set up bp to access the arguments
push di ; save di
cld ; set search direction to forwards
mov ax,[bp+6] ; ax = word to replicate
mov di,[bp+8] ; di = address to start reps
mov cx,[bp+10] ; cx = number of replications
rep stosw ; search for a newline
pop di ; restore di
pop bp ; restore bp
ret
_repword endp
;
;
; mouse event (software) interrupt handler
;
pgmds dw ?
;
;
;************************ _movwords *************************
;
public _movwords
;
; movwords(wordToReplicate, startAddress, numberOfReplications);
; char *startAddress;
; int wordToReplicate, numberOfReplications;
;
_movwords proc far
push bp ; save bp
mov bp,sp ; set up bp to access the arguments
push ds ; save ds
push es ; save es
push si ; save si
push di ; save di
cld ; set move direction to forwards
;
mov ax,[bp+6]
mov ds,ax
mov si,[bp+8] ; si = address of source data
mov ax,[bp+10] ; ax = word to replicate
mov es,ax
mov di,[bp+12] ; di = address of destination data
;
mov cx,[bp+14] ; cx = number of replications
sar cx,1 ; convert to a word count
rep movsw ; move the word
;
pop di ; restore di
pop si ; restore si
pop es ; restore es
pop ds ; restore ds
pop bp ; restore bp
ret
_movwords endp
;
;
;************************ _mbintr *************************
;
_mbintr proc far
cli ; disable hardware interrupts
;
; first save all the registers on entry
;
push ds ; save ds
push si ; save si
push cx ; save cx
push bx ; save bx
push ax ; save ax
;
push dx ; save dx
push cx ; save cx
push bx ; save bx
push ax ; save ax
;
; set us DS to Point's DS since the interrupt mechanism does not
; set it (how could it?)
;
mov ds,pgmds
;
; now compute the address of the event slot to put this in
; and store the next value (no interrupts so not need to wait on the store)
;
mov bx,_evaddr ; address of the event array
mov ax,_evtail ; where the last event was put
inc ax ; move to the next event
cmp ax,30 ; do modulo adjustment?
jl l1
sub ax,ax
l1:
mov _evtail,ax ; record the increment so C can see it
mov cl,3 ; 4 words/event x 2 bytes/word
shl ax,cl ; get an offset in 8 byte chunks
add bx,ax ; address of the next event
;
; store the four event words in the event slot
;
pop [bx+0] ; ax on entry moved to event slot
pop [bx+2] ; bx on entry moved to event slot
pop [bx+4] ; cx on entry moved to event slot
pop [bx+6] ; dx on entry moved to event slot
;
; restore registers
;
pop ax
pop bx
pop cx
pop si
pop ds
;
; done
;
sti ; re-enable interrupts
ret
_mbintr endp
;
;************************ _evinit *************************
;
; set up mbintr as the mouse software interrupt handler
;
_evinit proc far
push bp ; save bp
mov bp,sp
push es ; save es
mov pgmds,ds ; save ds for later
;
mov ax,12 ; set subroutine mask
mov cx,7FH ; interrupt on mouse buttons
mov dx,offset _mbintr; address of interrupt handler
push cs ; move cs to es
pop es
int 51 ; mouse function call
;
pop es
pop bp
ret
_evinit endp
;
;************************ _getvect *************************
;
;
public _getvect
_getvect PROC far
push bp ; save bp
mov bp,sp
push es ; save es
mov al,[bp+6] ; first arg is vector num
mov ah,35H
int 21H ; dos function call
mov dx,es
mov ax,bx
pop es
pop bp
ret
_getvect endp
;
public _matchdn
;
; match = matchdn(text, textLength, pat, patlength);
; char *text, *pat, *match;
; int textLength, patLength;
;
_matchdn proc far
push bp
mov bp,sp
push si ; save si
push di ; save di
push es ; save es
push ds ; move ds to es since di used a ds base
pop es ; in medium model not always(es==ds)
cld ; set search direction to forward
mov cx,[bp+8] ; cx = length(text)
sub cx,[bp+12] ; cx = length(text)-length(pat)
jl notFound ; text shorter than pat
inc cx ; + 1
mov di,[bp+6] ; di --> text
loop1:
mov si,[bp+10] ; si --> pat
mov al,[si] ; al = first char in pat
repne scasb ; search for first char in pat
jne notFound ; last comparison was not equal
; so cx got to zero w/o finding char
mov dx,cx ; save text's cx
mov bx,di ; save text's di
mov cx,[bp+12] ; match for length of pat
dec cx ; we already matched the first char
jz foundIt ; pat is only one character long
mov si,[bp+10] ; the cmpsb uses this
inc si ; first char already was matched
; di is already set up
repe cmpsb ; compare the strings
je foundIt ; last compare was equal so we matched
mov cx,dx ; restore cx
mov di,bx ; the repe cmpsb changed di
jmp loop1
;
notFound:
xor ax,ax ; return 0 == NULL
jmp retlab
foundIt:
mov ax,bx ; bx = saved di (beginning of match)
dec ax ; di was one past the start of
; the match
retlab:
pop es
pop di
pop si
pop bp
ret
_matchdn endp
;
;************************ _matchup *************************
;
;
public _matchup
;
; match = matchup(text, textLength, pat, patlength);
; char *text, *pat, *match;
; int textLength, patLength;
;
_matchup proc far
push bp
mov bp,sp
push si ; save si
push di ; save di
push es ; save es
push ds ; move ds to es since di used a ds base
pop es ; in medium model not always(es==ds)
mov cx,[bp+8] ; cx = length(text)
sub cx,[bp+12] ; cx = length(text)-length(pat)
jl notupFound ; text shorter than pat
inc cx ; + 1
mov di,[bp+6] ; di --> text
add di,cx ; start cx bytes up since we are
; searching backwards (std)
loopup:
mov si,[bp+10] ; si --> pat
mov al,[si] ; al = first char in pat
std ; set search direction to backward
repne scasb ; search for first char in pat
jne notupFound ; last comparison was not equal
; so cx got to zero w/o finding char
mov dx,cx ; save text's cx
mov bx,di ; save text's di
mov cx,[bp+12] ; match for length of pat
dec cx ; we already matched the first char
jz foundupIt ; pat is only one character long
mov si,[bp+10] ; the cmpsb uses this
inc si ; first char already was matched
; di is already set up
cld ; set search direction to forward
repe cmpsb ; compare the strings
je foundupIt ; last compare was equal so we matched
mov cx,dx ; restore cx
mov di,bx ; the repe cmpsb changed di
jmp loopup
;
notupFound:
xor ax,ax ; return 0 == NULL
jmp retup
foundupIt:
mov ax,bx ; bx = saved di (beginning of match)
dec ax ; di was one past the start of
; the match
retup:
cld ; set search direction to forward
pop es
pop di
pop si
pop bp
ret
_matchup endp
;
;************************ _match2dn *************************
;
public _match2dn
;
; match = match2dn(text, textLength, ch1);
; char far *text;
; char *match, ch1;
; int textLength;
;
_match2dn proc far
push bp
mov bp,sp
push di ; save di
push es ; save es
cld ; set search direction to forward
;
; look for the first character
;
mov di,[bp+6] ; di --> text
mov es,[bp+8] ; es = segment of text
mov cx,[bp+10] ; cx = length(text)
mov al,[bp+12] ; al = first char in pat
repne scasb ; search for first char
je found2It ; last comparison w